# Copyright (c) 2018 Presto Labs Pte. Ltd.
# Author: leon

from coin.exchange.base.kr_rest.currency import NativeCurrency
from coin.exchange.huobi.kr_rest.constants import currency_list


def to_native_currency(currency_str):
  assert currency_str in currency_list, currency_str
  native_currency_str = currency_str.upper()
  return native_currency_str


def from_native_currency(native_currency_str):
  assert native_currency_str.upper() == native_currency_str
  currency_str = native_currency_str.upper()
  assert currency_str in currency_list, native_currency_str
  return currency_str


class PrexCurrency(NativeCurrency):
  _exchange = "Prex"

  def __init__(self, currency):
    assert currency in currency_list, (currency)
    super().__init__(currency, to_native_currency(currency))

  @classmethod
  def FromStrCurrencyImpl(cls, currency_str, current_datetime):
    return PrexCurrency(currency_str)

  @classmethod
  def FromStrNativeCurrencyImpl(cls, native_currency_str, current_datetime):
    return PrexCurrency(from_native_currency(native_currency_str))
